package com.pearl.sharding.level.table.demo.algorithm;

import cn.hutool.core.collection.ListUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingValue;

import java.util.Collection;

/**
 * Hint 分片算法需要用户实现 `org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm` 接口。
 * Apache ShardingSphere 在进行路由时，将会从 HintManager 中获取分片值进行路由操作。
 * @author TD
 * @version 1.0
 * @date 2024/2/27
 */
@Slf4j
public class MyHintShardingAlgorithm implements HintShardingAlgorithm<Comparable<?>> {

    @Override
    public Collection<String> doSharding(Collection<String> collection, HintShardingValue<Comparable<?>> hintShardingValue) {
        log.error("MyHintShardingAlgorithm................");
        return ListUtil.toList("1");
    }
}
